/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package iluscodefx;



import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.fxml.JavaFXBuilderFactory;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
//import ws.negocio.IlusCodeException_Exception;

/**
 *
 * @author fernanxi
 */
public class IlusCodeFX extends Application {
    
    private Stage stage;
    
    
    private static IlusCodeFX instance;
    
    public IlusCodeFX() {
        instance = this;
    }

    public Stage getStage() {
        return stage;
    }

    public static IlusCodeFX getInstance() {
        return instance;
    }
    
    
    public static void main(String[] args) {
        Application.launch(args);
        
    }
    
    @Override
    public void start(Stage primaryStage) throws Exception 
    {
      try {
            stage= primaryStage;
            
            gotoGUI();
           
            primaryStage.show();
        } catch (Exception ex) {
            Logger.getLogger(IlusCodeFX.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
     
    
     private void gotoLogin() {
        try {
            replaceSceneContent("login.fxml");
        } catch (Exception ex) {
            Logger.getLogger(IlusCodeFX.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
     
      private void gotoCreate() {
        try {
            replaceSceneContent("Create.fxml");
        } catch (Exception ex) {
            Logger.getLogger(IlusCodeFX.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
     
      private void gotoGUI() {
        try {
            replaceSceneContent("GUI.fxml");
        } catch (Exception ex) {
            Logger.getLogger(IlusCodeFX.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
      
      private void gotoPruebaArchivo() {
        try {
            replaceSceneContent("PruebaArchivo.fxml");
        } catch (Exception ex) {
            Logger.getLogger(IlusCodeFX.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
     
     private Parent replaceSceneContent(String fxml) throws Exception {
        Parent page = (Parent) FXMLLoader.load(IlusCodeFX.class.getResource(fxml), null, new JavaFXBuilderFactory());
        Scene scene = stage.getScene();
        if (scene == null) {
            scene = new Scene(page, 1000, 650);
            scene.getStylesheets().add(IlusCodeFX.class.getResource("demo.css").toExternalForm());
            stage.setScene(scene);
        } else {
            stage.getScene().setRoot(page);
        }
        stage.sizeToScene();
        return page;
    }
    
    
}